    <?php defined('BASEPATH') OR exit('No direct script access allowed'); ?><!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <link rel="Bookmark" href="/favicon.ico" >
    <link rel="Shortcut Icon" href="/favicon.ico" />
    <!--[if lt IE 9]>
    <script type="text/javascript" src="/public/js/html5shiv.js"></script>
    <script type="text/javascript" src="/public/js/respond.min.js"></script>
    <![endif]-->
    <link rel="stylesheet" type="text/css" href="/public/plugins/h-ui/css/H-ui.min.css" />
    <link rel="stylesheet" type="text/css" href="/public/plugins/h-ui.admin/css/H-ui.admin.css" />
    <link rel="stylesheet" type="text/css" href="/public/plugins/Hui-iconfont/iconfont.css" />
    <link rel="stylesheet" type="text/css" href="/public/plugins/h-ui.admin/skin/default/skin.css" id="skin" />
    <link rel="stylesheet" type="text/css" href="/public/plugins/h-ui.admin/css/style.css" />
    <link rel="stylesheet" type="text/css" href="/public/plugins/laydate/skins/default/laydate.css"/>
    <!--[if IE 6]>
    <script type="text/javascript" src="/public/js/DD_belatedPNG_0.0.8a-min.js" ></script>
    <script>DD_belatedPNG.fix('*');</script>
    <![endif]-->
    <title>快方管理后台</title>
    <meta name="keywords" content="">
    <meta name="description" content="">
    <style type="text/css">
        .date{
            width: 100px;
        }
    </style>
</head>
<body class="big-page">

<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 门店管理 <span
        class="c-gray en">&gt;</span> 门店列表 <a class="btn btn-success radius r"  style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新">
        <i class="Hui-iconfont">&#xe68f;</i></a></nav>
<div class="Hui-article">
    <article class="cl pd-20">
        <div class="skin-minimal mt-5">
            <form id="form1" method="post">
            <label for="status" class="">配送平台:</label>
            <span class="select-box" style="width: 150px;">
                <?php
                    foreach ($result_platform as $key => $value) {  ?>
                            <input type="checkbox" name="ID[]" value="<?=$value['ID'] ?>"><?=$value['TL'] ?>
                        
                <?php    }
                ?>
            </span> 
            
            <input class="update btn btn-success radius" type="button" value="开店">
            
            </form>
        </div>
            
        <div class="mt-10">
            <table class="table table-border table-bordered table-bg table-hover table-sort table-responsive" id="dataTables">
                <thead>
                <tr class="text-c">
                    <th>#</th>
                    <th>门店名称</th>
                    <th>配送方式与时间</th>
                    <th>编辑</th>
                </tr>
                </thead>
                <tbody>
                    <!-- <?php foreach ($data as $k => $v) {?>
                    <tr>
                        <td style="text-align: center;"><?=$v['ID'] ?></td>
                        <td style="text-align: center;"><?=$v['Caption'] ?></td>
                        <td style="text-align: center;">
                        <?php foreach ($result_platform as $key => $value) {
                           if(in_array($value['ID'], explode(',',$v['PTID'])))
                           {
                                echo $value['TL'].'&nbsp;&nbsp;&nbsp;'; 
                           }                            
                        }?>
                        </td>
                        <td style="text-align: center;">
                            <?php 
                                $btm = explode(',',$v['BTM']);
                                $etm = explode(',',$v['ETM']);
                                $arr = array_combine($btm, $etm);
                                // var_dump($arr);
                                foreach ($arr as $key => $value) {
                                    echo $key.'——'.$value.'&nbsp;&nbsp;&nbsp;';
                                }
                            ?>
                        </td>                        
                        <td style="text-align: center;">
                            <a class="plantforms" data-yid="<?=$v['ID'] ?>" href="javascript:void(0);">设置配送方式与配送时间</a>                                            
                        </td>                    
                    </tr> 
                    <?php }?> -->
                </tbody>
            </table>
        </div>
    </article>
</div>

<script type="text/javascript" src="/public/js/jquery.min.js"></script>
<script type="text/javascript" src="/public/plugins/layer/layer.js"></script>
<script type="text/javascript" src="/public/plugins/h-ui/js/H-ui.min.js"></script>
<script type="text/javascript" src="/public/plugins/h-ui.admin/js/H-ui.admin.js"></script>
<script type="text/javascript" src="/public/plugins/jquery.contextmenu/jquery.contextmenu.r2.js"></script>
<script type="text/javascript" src="/public/plugins/datatables/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="/public/plugins/laydate/laydate.js"></script>
<script type="text/javascript">
    // $('.plantforms').on('click', function () {
    //     var yid = $(this).data("yid");
    //     layer.open({
    //       type: 2,
    //       title: '设置配送方式与配送时间',
    //       shadeClose: true,
    //       shade: 0.8,
    //       area: ['500px', '450px'],
    //       content: '/Plantforms/setPeisong?yid=' + yid
    //     }); 
    // });
    $('.date').on('click', function () {
        laydate({format: 'YYYY-MM-DD', istime: false})
    });
    var dataTables = $('#dataTables').my_data_table({
        "fnRowCallback" :  function (sName, oData, sExpires, sPath) {

        var store_id = oData.ID;
        
        $.ajax({
            url : "/Plantforms/showPeisong",
            type: "GET",
            dataType: "json",
            data: {"store_id" : store_id},
            success:function(res){
                var html = "";

                for(k in res){
                    var platform = res[k]['platform'].join("&emsp;")
                    html += "<span style='font-size:14px;margin-top:10px;display:block;'>" + res[k]['BTM']+"-"+res[k]['ETM'] + "&emsp;" + platform +"<br></span>";
                }
                $('td:eq(2)',sName).html(html);

            }
        })

        return sName;
    },
        columns: [
            {data: 'ID'},
            {data: 'Caption'},
            {data: 'ID', searchable: false, orderable: false, render: function (data, type, row, meta){
                    
                return '';
            }},
            // {data: 'Ps'},
            {data: 'ID', searchable: false, orderable: false, render: function (data, type, row, meta){
                    var store_name = row.Caption;
                    html = "<a data-store_name='"+store_name+"' class='plantforms' href='javascript:void(0);' data-yid="+data+">设置配送方式与配送时间</a>";
                return html;
            }}
        ]
    });

    $(document).on("click", ".peisong", function(){
        var yid = $(this).data("yid");
        layer.open({
          type: 2,
          title: '显示配送方式与配送时间',
          shadeClose: true,
          shade: 0.8,
          area: ['600px', '450px'],
          content: '/Plantforms/showPeisong?yid=' + yid
        }); 
    })    

    $(document).on("click", ".plantforms", function(){
        var yid = $(this).data("yid");
        var store_name = $(this).data("store_name");
        layer.open({
          type: 2,
          title: store_name,
          shadeClose: true,
          shade: 0.8,
          area: ['60%', '450px'],
          content: '/Plantforms/setPeisong?yid=' + yid
        }); 
    })

    $(".update").bind("click", function(){
        // alert(1);
        $.ajax({
            url: '/Plantforms/updatePlatforms',
            type: "POST",
            dataType: "json",
            data: $("#form1").serialize(),
            success:function(res){
                if(res.status == "success"){
                    alert("修改成功");
                    window.location.reload();
                }else{
                    alert(res.info);
                }

            }
        }); 
        return true; 
    })
</script>
</body>
</html>
